home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
examples
/
demo
/
demosrc
/
d_vibmembr.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
71KB
|
1,976 lines
$Id: d_vibmembr.pro,v 1.19 1997/04/19 22:48:46 tremblay Exp $
;
; Copyright (c) 1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;
;+
; FILE:
; d_vibmembr.pro
;
; CALLING SEQUENCE: d_vibmembr
;
; PURPOSE:
; Shows an animation of a vibrating membrane in IDL 5.0.
;
; MAJOR TOPICS: Visualization.
;
; CATEGORY:
; IDL 5.0
;
; INTERNAL FUNCTIONS and PROCEDURES:
; pro vib_setShades - Set the shading colors overlay
; fun toggle_state - Toggle off/on name
; fun cw_iat - Compound widget : animation tool in 5.0
; pro vibmembr_Event - Event handler
; pro vibmembr_Cleanup - Cleanup
; pro d_vibmembr - Main procedure
;
; EXTERNAL FUNCTIONS, PROCEDURES, and FILES:
; pro iniobj - Create the objects
; pro vibmem - Compute the vibrating membrane (main surface)
; pro bumps - Compute 2-D wave data set for shading color
; pro cw_iat - Compound widget animation tool in 5.0.
; pro trackball__define - Create the trackball object
; fun gettips - Read the tip file
; pro widtips - Create the tip widgets text
; pro sizetips - Size the tip widgets text
; pro trackball__define - Create the trackball object
; vibmembr.txt
; vibmembr.tip
;
; REFERENCE: IDL Reference Guide, IDL User's Guide
;
; NAMED STRUCTURES:
; none.
;
; COMMON BLOCS:
; none.
;
; MODIFICATION HISTORY: Written by DAT,RSI, July 1996 New GUI
; vibmem.pro written by Steve Kranock, RSI, 1996
;
;-
; -----------------------------------------------------------------------------
;
; Purpose: Set the shading colors.
; This procedure changes the vertices (shades) colors. When
; the input initial is less that final, the colors are those
; that corresponds to the surface height ( 4-D). Otherwise,
; the colors frames are set in an inverse order ( this gives a
; 6-D mode.
;
FUNCTION bumps, $
kindex ; IN: time index
; Create a 2-d time dependent wave function.
;
; 2 harmonics in th x direction,
; 2 harmonics in th y direction
; the z direction is the product of
; the x and y waves...
;
; Initialize constants
;
kvect = fltarr(4)
kvect = [10.0, 16.4, 13.0, 11.4]
kvect = kvect/200
k = kindex
time = 2.05 * !pi* (0.6 - 0.3*cos(float(k)/100.))
nk = float(k)/10.0 * (-0.7)
; The data set has diumension ndim x ndim.
;
ndim = 21
wvect = kvect * time
a1 = 1.0
a2 = 1.0
a3 = 1.0
a4 = 1.0
b1 = 1.0
b2 = 1.0
b3 = 1.0
b4 = 1.0
x = FINDGEN(ndim)*2
y = FINDGEN(ndim)*2
z = fltarr(ndim,ndim)
z = z - z
for i = 0, ndim-1 do begin
for j = 0, ndim-1 do begin
z(i,j) = z(i,j) + ( a1*cos(wvect(0)*x(i)+nk) + $
b1*sin(wvect(0)*x(i)+nk) + $
a2*cos(wvect(1)*x(i)+nk) + $
b2*sin(wvect(1)*x(i)+nk) ) * $
(a3*cos(wvect(2)*y(j)+2.0*nk) + $
b3*sin(wvect(2)*y(j)+2.0*nk) + $
a4*cos(wvect(3)*y(j)+2.0*nk) + $
b4*sin(wvect(3)*y(j)+2.0*nk) )
endfor
endfor
RETURN, z
end ;
; $Id: cw_iat.pro,v
;
; Copyright (c) 1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;
;+
; FILE:
; cw_iat.pro
;
; CALLING SEQUENCE: cw_iat
;
; PURPOSE:
; Compoihnd widget of the animation tool in IDL 5.0.
;
; MAJOR TOPICS: Visualization and animation.
;
; CATEGORY:
; IDL 5.0
;
; INTERNAL FUNCTIONS and PROCEDURES:
; fun getRotation - Rotation values of the satellite
; fun createSatellite - create the satellite object
; fun findE - Compute the eccentric anomaly
; fun findPosition - Compute the satelitte's ephemeris.
; pro orbit_Event - Event handler
; pro orbit_Cleanup - Cleanup
; pro orbit - Main procedure
;
; EXTERNAL FUNCTIONS, PROCEDURES, and FILES:
; pro trackball__define - Create the trackball object
;
; REFERENCE: IDL Reference Guide, IDL User's Guide
;
; NAMED STRUCTURES:
; none.
;
; COMMON BLOCS:
; none.
;
; MODIFICATION HISTORY: Written by DAT,RSI, July 1996 New GUI
; Modified by DAT, RSI, february 1997, add
; trackball object and cleanup the code.
;
;-
;---------------------------------------------------------------------------
;
; Purpose: On realization of the main base (outside this CW), assigns
; the widow object to the parent of the widget draw.
;
pro DRAW1CB, $
sEvent ; IN: event structure.
WIDGET_CONTROL, sEvent, GET_VALUE = oWindow
wRightBase = WIDGET_INFO(sEvent, /PARENT)
WIDGET_CONTROL, wRightBase, SET_UVALUE =oWindow , /NO_COPY
end
;---------------------------------------------------------------------------
;
; Purpose: Event handler for events occuring within the compound widget.
; these event are : bitmap buttons, frame speed slider,
; frame indicator slider, and the reset button.
;
pro cw_iatEvent, $
sEvent ; IN: event structure.
; Get the drawWindow object identifier
; which is the user value of the right base.
;
child = WIDGET_INFO(sEvent.handler, /CHILD)
WIDGET_CONTROL, child, GET_UVALUE = sState, /NO_COPY
WIDGET_CONTROL, sState.wRightBase, $
GET_UVALUE=temp, /NO_COPY
oWindow = temp
WIDGET_CONTROL, sState.wRightBase, $
SET_UVALUE=temp, /NO_COPY
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
WIDGET_CONTROL, sEvent.id, GET_UVALUE= uValue
; Branch to the appropriate event.
;
case uValue of
'ACTIVE' : begin
; Toggle the active button.
;
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
WIDGET_CONTROL, sState.wActiveButton, GET_VALUE=activeFlag
sState.activeFlag = activeFlag
if (sState.activeFlag EQ 1) then begin
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SET_VALUE=sState.frameIndex
if (sState.stopFlag EQ 1) then begin
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SENSITIVE=1
endif
endif else begin
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SENSITIVE=0
endelse
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
end ; of ACTIVE
; The timer event create the loop because another timer event
; is generated given that the stop button has not been pushed.
;
'TIMER' : begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
stopFlag = sState.stopFlag
; Animate only if the stop flag has not been pushed
; ( i.e. stopflag = 0).
;
if (stopFlag EQ 0) then begin
; Hide the previous frame (model).
;
i = sState.previousIndex
sState.oMovableModelArray(i)->SetProperty, HIDE=1
sState.oStaticModelArray(i)->SetProperty, HIDE=1
sState.frameIndex = sState.frameIndex + $
sState.frameIncrement
sState.currentIndex = sState.frameIndex
if (sState.cycleFlag EQ 0 ) then begin
; Reset the frame index , First if not in cycle mode.
;
if (sState.frameIndex EQ sState.nframes) then begin
sState.frameIndex = 0
endif
if (sState.frameIndex LT 0) then begin
sState.frameIndex = sState.nframes-1
endif
endif else begin
; Reset the frame index if in
; cycle mode ( back and forth).
;
if (( sState.frameIndex EQ (sState.nframes)) OR $
(sState.frameIndex EQ -1) ) then begin
sState.frameIncrement = -sState.frameIncrement
sState.frameIndex = sState.frameIndex + $
2*sState.frameIncrement
endif
endelse
; Draw the current frame.
;
i = sState.frameIndex
sState.oMovableModelArray(i)->SetProperty, HIDE=0
sState.oStaticModelArray(i)->SetProperty, HIDE=0
oWindow->Draw, sState.oView
sState.previousIndex = i
if (sState.activeFlag EQ 1) then begin
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SET_VALUE= sState.frameIndex
endif
; Accumulate the number of frames to compute
; the frame rate.
;
sState.count = sState.count + 1
; If count is 5 , reset it zero,
; Display the frame rate.
;
if (sState.count EQ 5) then begin
sState.finalTime = SYSTIME(1)
delta = sState.finalTime - sState.startTime
rate = FLOAT(5.0/ delta)
WIDGET_CONTROL, sState.wFramesRateLabel, $
SET_VALUE= STRING(rate, FORMAT='(f6.2)' )
sState.count = 0
sState.startTime = sState.finalTime
endif
WIDGET_CONTROL, sState.wButtonBase, $
TIMER=1.0e-4 + sState.delay
sState.previousIndex = sState.frameIndex
endif ; of StopFlag = 0
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
end ; of TIMER
; Handle the play forward button.
;
'PLAYFORWARD' : begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
if( sState.forwardFlag EQ 0) then begin
if(sState.stopflag EQ 1) then begin
sState.count = 0
sState.startTime = systime(1)
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SENSITIVE=0
endif
sState.frameIncrement = 1
sState.cycleFlag = 0
sState.forwardFlag = 1
sState.backwardFlag = 0
sState.stopFlag = 0
if (sState.frameIndex EQ sState.nframes-1) $
then sState.frameIndex = 0
; The stop button has not been pushed.
;
sState.stopFlag = 0
WIDGET_CONTROL, sState.wplayFButton, $
SET_VALUE=sState.BMB.forwardOn
WIDGET_CONTROL, sState.wplayBButton, $
SET_VALUE=sState.BMB.backward
WIDGET_CONTROL, sState.wCycleButton, $
SET_VALUE=sState.BMB.cycle
WIDGET_CONTROL, sState.wStopButton, $
SET_VALUE=sState.BMB.stop
WIDGET_CONTROL, sState.wButtonBase, $
TIMER=1.0e-4 + sState.delay
endif
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
end ; of PLAYFORWARD
; Handle the play forward button.
;
'PLAYBACKWARD' : begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
if (sState.backwardFlag EQ 0) then begin
if (sState.frameIndex EQ 0) then $
sState.frameIndex = sState.nframes-1
if(sState.stopflag EQ 1) then begin
sState.count = 0
sState.startTime = systime(1)
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SENSITIVE=0
endif
sState.cycleFlag = 0
sState.forwardFlag = 0
sState.backwardFlag = 1
sState.stopFlag = 0
sState.frameIncrement = -1
WIDGET_CONTROL, sState.wplayFButton, $
SET_VALUE=sState.BMB.forward
WIDGET_CONTROL, sState.wplayBButton, $
SET_VALUE=sState.BMB.backwardOn
WIDGET_CONTROL, sState.wCycleButton, $
SET_VALUE=sState.BMB.cycle
WIDGET_CONTROL, sState.wStopButton, $
SET_VALUE=sState.BMB.stop
WIDGET_CONTROL, sState.wButtonBase, $
TIMER=1.0e-4 + sState.delay
endif
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
end ; of PLAYBACKWARD
; Handle the top button(stops the animation).
;
'STOP' : begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
if( sState.stopFlag EQ 0) then begin
sState.cycleFlag = 0
sState.forwardFlag = 0
sState.backwardFlag = 0
sState.stopFlag = 1
WIDGET_CONTROL, sState.wAreaDraw, DRAW_MOTION = 0
WIDGET_CONTROL, sState.wplayFButton, $
SET_VALUE=sState.BMB.forward
WIDGET_CONTROL, sState.wplayBButton, $
SET_VALUE=sState.BMB.backward
WIDGET_CONTROL, sState.wCycleButton, $
SET_VALUE=sState.BMB.cycle
WIDGET_CONTROL, sState.wStopButton, $
SET_VALUE=sState.BMB.stopOn
if (sState.wResetButton NE 0L) then begin
WIDGET_CONTROL, sState.wResetButton, SENSITIVE=1
endif
if (sState.activeFlag EQ 1) then begin
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SENSITIVE=1
endif else begin
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SENSITIVE=0
endelse
endif
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
RETURN
end ; of STOP
; Play back and forth (cycle) button.
;
'CYCLE' : begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
if (sState.cycleFlag EQ 0) then begin
if (sState.stopflag EQ 1) then begin
sState.count = 0
sState.startTime = SYSTIME(1)
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SENSITIVE=0
endif
sState.cycleFlag = 1
sState.forwardFlag = 0
sState.backwardFlag = 0
sState.stopFlag = 0
WIDGET_CONTROL, sState.wplayFButton, $
SET_VALUE=sState.BMB.forward
WIDGET_CONTROL, sState.wplayBButton, $
SET_VALUE=sState.BMB.backward
WIDGET_CONTROL, sState.wCycleButton, $
SET_VALUE=sState.BMB.cycleOn
WIDGET_CONTROL, sState.wStopButton, $
SET_VALUE=sState.BMB.stop
WIDGET_CONTROL, sState.wButtonBase, $
TIMER=1.0e-4 + sState.delay
endif
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
end ; of CYCLE
; Reset the initial orientation of the display and
; show the first frame (frame index = 0).
;
'RESET': begin
; Reset to the first frame (if play mode was forward), or
; to the last frame ( if play mode was backward). Also
; restore the initial tranformation matrix.
;
WIDGET_CONTROL, child, GET_UVALUE = sState, /NO_COPY
if (sState.frameIncrement EQ 1) then begin
sState.frameIndex = 0
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SET_VALUE=0
i = 0
endif else begin
sState.frameIndex = sState.nframes-1
i = sState.nframes-1
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
SET_VALUE = sState.nframes-1
endelse
j=i
sState.oMovableRotationModel->SetProperty, $
TRANSFORM=sState.initTransform
for i = 0, sState.nframes - 1 do begin
sState.oMovableModelArray(i)->SetProperty, HIDE=1
sState.oStaticModelArray(i)->SetProperty, HIDE=1
endfor
sState.oMovableModelArray(j)->SetProperty, HIDE=0
sState.oStaticModelArray(j)->SetProperty, HIDE=0
sState.previousIndex = j
oWindow->Draw, sState.oView
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
end ; of RESET
; Responds for cursor event in the draw area.
;
'DRAWING': begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
; Expose.
;
if (sEvent.type EQ 4) then begin
oWindow->Draw, sState.oView
WIDGET_CONTROL, child, SET_UVALUE = sState, /NO_COPY
RETURN
endif
; Handle trackball update.
;
bHaveTransform = sState.oTrack->Update(sEvent, $
TRANSFORM=qmat)
if (bHaveTransform NE 0) then begin
sState.oMovableRotationModel->GetProperty, TRANSFORM=t
mt = t # qmat
sState.oMovableRotationModel->SetProperty, TRANSFORM=mt
endif
; Handle button press here.
;
if (sEvent.type EQ 0) then begin
sState.btndown = 1B
oWindow->SetProperty, QUALITY=sState.dragq
WIDGET_CONTROL,sState.wAreaDraw, /DRAW_MOTION
endif
; Handle draw motion here.
;
if ((sEvent.type EQ 2) and (sState.btndown EQ 1b)) $
then begin
if (bHaveTransform) then $
oWindow->Draw, sState.oView
endif
; Handle release button here.
;
if (sEvent.type EQ 1) then begin
if (sState.btndown EQ 1B) then begin
oWindow->SetProperty, QUALITY=2
oWindow->Draw, sState.oView
endif
sState.btndown = 0B
WIDGET_CONTROL, sState.wAreaDraw, DRAW_MOTION=0
endif
WIDGET_CONTROL, child, SET_UVALUE = sState, /NO_COPY
end ; of DRAWING
; Reset the delay between frames using the speed slider.
;
'SPEED' : begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
WIDGET_CONTROL, sState.wFramesSpeedSlider, $
GET_VALUE=speedvalue
if (speedvalue EQ 100) then begin
sState.delay = 0.0
endif else begin
sState.delay = 3.0 / (3.0 + speedvalue )
endelse
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
end ; of SPEED
; Display the frame selected by the indicator slider.
;
'INDICATOR': begin
WIDGET_CONTROL, child, GET_UVALUE=sState, /NO_COPY
wCWBase = sState.wCWBase
WIDGET_CONTROL, sState.wFramesIndicatorSlider, $
GET_VALUE = frameIndex
i = sState.previousIndex
sState.oMovableModelArray(i)->SetProperty, HIDE=1
sState.oStaticModelArray(i)->SetProperty, HIDE=1
sState.frameIndex = frameIndex
sState.previousIndex = frameIndex
sState.oMovableModelArray(frameIndex)->SetProperty, HIDE=0
sState.oStaticModelArray(frameIndex)->SetProperty, HIDE=0
oWindow->Draw, sState.oView
WIDGET_CONTROL, child, SET_UVALUE=sState, /NO_COPY
; We may return here because the frame indicator slider
; is not sensitized while in a playing mode.
;
RETURN
end ; of INDICATOR
endcase ; of case widget_info(name)
end ; of cw_iatEvent
;---------------------------------------------------------------------------
;
; Purpose: Initialize (create) the bitmap buttons.
;
function InitBitmapButtons
stop = [[000B, 000B, 000B],[000B, 000B, 000B],$
[000B, 000B, 000B],[000B, 000B, 000B],$
[240B, 255B, 015B],[240B, 255B, 015B],$
[240B, 255B, 015B],[112B, 000B, 014B],$
[112B, 255B, 014B],[112B, 255B, 014B],$
[112B, 255B, 014B],[112B, 255B, 014B],$
[112B, 255B, 014B],[112B, 255B, 014B],$
[112B, 255B, 014B],[112B, 255B, 014B],$
[112B, 000B, 014B],[240B, 255B, 015B],$
[240B, 255B, 015B],[240B, 255B, 015B],$
[000B, 000B, 000B],[000B, 000B, 000B],$
[000B, 000B, 000B],[000B, 000B, 000B]]
stopon = [[255B, 255B, 255B],[255B, 255B, 255B],$
[255B, 255B, 255B],[255B, 255B, 255B],$
[015B, 000B, 240B],[015B, 000B, 240B],$
[015B, 000B, 240B],[143B, 255B, 241B],$
[143B, 000B, 241B],[143B, 000B, 241B],$
[143B, 000B, 241B],[143B, 000B, 241B],$
[143B, 000B, 241B],[143B, 000B, 241B],$
[143B, 000B, 241B],[143B, 000B, 241B],$
[143B, 255B, 241B],[015B, 000B, 240B],$
[015B, 000B, 240B],[015B, 000B, 240B],$
[255B, 255B, 255B],[255B, 255B, 255B],$
[255B, 255B, 255B],[255B, 255B, 255B]]
forward = [[000B, 000B, 000B],[000B, 000B, 000B],$
[000B, 000B, 000B],[056B, 000B, 000B],$
[248B, 000B, 000B],[248B, 003B, 000B],$
[248B, 015B, 000B],[248B, 063B, 000B],$
[248B, 255B, 000B],[248B, 255B, 003B],$
[248B, 255B, 015B],[248B, 255B, 031B],$
[248B, 255B, 031B],[248B, 255B, 015B],$
[248B, 255B, 003B],[248B, 255B, 000B],$
[248B, 063B, 000B],[248B, 015B, 000B],$
[248B, 003B, 000B],[248B, 000B, 000B],$
[056B, 000B, 000B],[000B, 000B, 000B],$
[000B, 000B, 000B],[000B, 000B, 000B]]
forwardOn = [[255B, 255B, 255B],[255B, 255B, 255B],$
[255B, 255B, 255B],[199B, 255B, 255B],$
[007B, 255B, 255B],[007B, 252B, 255B],$
[007B, 240B, 255B],[007B, 192B, 255B],$
[007B, 000B, 255B],[007B, 000B, 252B],$
[007B, 000B, 240B],[007B, 000B, 224B],$
[007B, 000B, 224B],[007B, 000B, 240B],$
[007B, 000B, 252B],[007B, 000B, 255B],$
[007B, 192B, 255B],[007B, 240B, 255B],$
[007B, 252B, 255B],[007B, 255B, 255B],$
[199B, 255B, 255B],[255B, 255B, 255B],$
[255B, 255B, 255B],[255B, 255B, 255B]]
backward = [[000B, 000B, 000B],[000B, 000B, 000B],$
[000B, 000B, 000B],[000B, 000B, 028B],$
[000B, 000B, 031B],[000B, 192B, 031B],$
[000B, 240B, 031B],[000B, 252B, 031B],$
[000B, 255B, 031B],[192B, 255B, 031B],$
[240B, 255B, 031B],[248B, 255B, 031B],$
[248B, 255B, 031B],[240B, 255B, 031B],$
[192B, 255B, 031B],[000B, 255B, 031B],$
[000B, 252B, 031B],[000B, 240B, 031B],$
[000B, 192B, 031B],[000B, 000B, 031B],$
[000B, 000B, 028B],[000B, 000B, 000B],$
[000B, 000B, 000B],[000B, 000B, 000B]]
backwardOn = [[255B, 255B, 255B],[255B, 255B, 255B],$
[255B, 255B, 255B],[255B, 255B, 227B],$
[255B, 255B, 224B],[255B, 063B, 224B],$
[255B, 015B, 224B],[255B, 003B, 224B],$
[255B, 000B, 224B],[063B, 000B, 224B],$
[015B, 000B, 224B],[007B, 000B, 224B],$
[007B, 000B, 224B],[015B, 000B, 224B],$
[063B, 000B, 224B],[255B, 000B, 224B],$
[255B, 003B, 224B],[255B, 015B, 224B],$
[255B, 063B, 224B],[255B, 255B, 224B],$
[255B, 255B, 227B],[255B, 255B, 255B],$
[255B, 255B, 255B],[255B, 255B, 255B]]
cycle = [[000B, 000B, 000B], [000B, 000B, 000B], [000B, 128B, 000B], $
[000B, 128B, 001B], [000B, 128B, 003B], [248B, 255B, 006B], $
[008B, 000B, 012B], [008B, 000B, 024B], [248B, 255B, 012B], $
[248B, 255B, 006B], [000B, 128B, 003B], [000B, 129B, 001B], $
[128B, 129B, 000B], [192B, 001B, 000B], [096B, 255B, 015B], $
[048B, 000B, 008B], [024B, 000B, 008B], [048B, 255B, 015B], $
[096B, 255B, 015B], [192B, 001B, 000B], [128B, 001B, 000B], $
[000B, 001B, 000B], [000B, 000B, 000B], [000B, 000B, 000B] ]
cycleOn = [[255B, 255B, 255B], [255B, 255B, 255B], [255B, 127B, 255B], $
[255B, 127B, 254B], [255B, 127B, 252B], [007B, 000B, 249B], $
[247B, 255B, 243B], [247B, 255B, 231B], [007B, 000B, 243B], $
[007B, 000B, 249B], [255B, 127B, 252B], [255B, 126B, 254B], $
[127B, 126B, 255B], [063B, 254B, 255B], [159B, 000B, 240B], $
[207B, 255B, 247B], [231B, 255B, 247B], [207B, 000B, 240B], $
[159B, 000B, 240B], [063B, 254B, 255B], [127B, 254B, 255B], $
[255B, 254B, 255B], [255B, 255B, 255B], [255B, 255B, 255B] ]
bitmapbutton = { Stop:stop, Forward:forward, $
Backward:backward, Cycle:cycle , $
ForwardOn : forwardOn, $
BackwardOn : backwardOn, $
CycleOn : cycleOn, StopOn : stopOn }
RETURN, bitmapButton
end ; of InitBitmaspButton
;---------------------------------------------------------------------------
;
; Purpose: This function is a compound widget that creates the
; animation tool for IDL 5.0. It returns the top level
; base of this
;
; The main feature is the interactivity capability.
; The object array of oMovableModelArray will be interactive
; meaning that the object array can be rotated interactivily
; with the clik-drag-release of the left mouse button
; suring the animation.
;
; The object array in oStaticModelArray will not be interactive.
; However, their content can be different for each frames.
;
function CW_IAT, $
wTopBase, $ ; IN: parent base identifier
oStaticModelArray, $ ; IN: Model array that is not interactive
oMovableModelArray, $ ; IN: Model array that is interactive
oMovableModel, $ ; IN: translation model
oMovableRotationModel, $ ; IN: rotation model
oMovableScalingModel, $ : IN: scaling model
oView, $ ; IN: view
oTrack, $ ; IN: trackball object (must be created outside )
oContainer, $ ; IN: container object (must be created outside )
nFrames, $ ; IN: number of frames.
Xsize = xsize, $ ; IN: (opt) drawing area x size (default =500)
Ysize = ysize, $ ; IN: (opt) drawing area y size (default =425)
Reset = reset, $ ; IN: (opt) createa reset button if set to 1.
Status = status ; OUT: returns 0 on failure, 1 on success
; Set status to OK.
;
status = 1
; Verify that all the parameters have been correctly
; passed.
;
if (N_Params() NE 10) then begin
status = 0
Message, 'ERROR : 10 parameters must be passed to cw_iat.pro'
endif
; Verify that the top level base is valid.
;
check = WIDGET_INFO(wTopBase, /VALID_ID)
if (check NE 1) then begin
status = 0
Message, 'ERROR : Top level base identifer is not valid.'
endif
; Set the default x and y size of the view area if not provided.
;
if (N_ELEMENTS(xsize) EQ 0) then xsize = 500
if (N_ELEMENTS(ysize) EQ 0) then ysize = 425
; Initialize the bitmap buttons (BitMap Button or BMB).
;
BMB = InitBitmapButtons()
; Create the cw base, child of the top level base(wTopBase).
;
wCWBase = WIDGET_BASE(wTopBase, COLUMN=2, /FRAME)
; Create a base for the left column.
; The left column contains functionality buttons.
;
wLeftBase = WIDGET_BASE(wCWBase, /BASE_ALIGN_CENTER, $
/COLUMN)
wButtonBase = WIDGET_BASE(wLeftBase, UVALUE='TIMER', /ROW)
wPlayBButton = WIDGET_BUTTON(wButtonBase, $
VALUE=BMB.backward, UVALUE='PLAYBACKWARD')
wStopButton = WIDGET_BUTTON(wButtonBase, $
VALUE=BMB.stopOn, UVALUE='STOP')
wPlayFButton = WIDGET_BUTTON(wButtonBase, $
VALUE=BMB.forward, UVALUE='PLAYFORWARD')
wCycleButton = WIDGET_BUTTON(wButtonBase, $
VALUE=BMB.cycle, UVALUE='CYCLE')
wSpeedBase = WIDGET_BASE(wLeftBase, /COLUMN)
wSpeedBaseLabel = WIDGET_LABEL(wSpeedBase, $
VALUE = "Animation Speed:")
wFramesSpeedBase = WIDGET_BASE(wSpeedBase, $
TITLE = "Animation Speed", /COLUMN, /FRAME)
wFramesRateBase = WIDGET_BASE(wFramesSpeedBase, /ROW)
wFramesPerSecLabel = WIDGET_LABEL(wFramesRateBase, $
VALUE = "Frames/Sec:")
wFramesRateLabel = WIDGET_LABEL(wFramesRateBase, $
VALUE = '00.00 ')
wSliderBase = WIDGET_BASE(wFramesSpeedBase, $
/COLUMN, /ALIGN_CENTER)
wfasttLbl = WIDGET_LABEL(wSliderBase, VALUE='Fast', $
/ALIGN_CENTER)
wFramesSpeedSlider = WIDGET_SLIDER(wSliderBase,$
/ALIGN_CENTER, $
/DRAG, VALUE = 100, UVALUE='SPEED', $
MAXIMUM = 100, MINIMUM = 0, /VERTICAL, $
/SUPPRESS_VALUE)
wSlowLbl = WIDGET_LABEL(wSliderBase, VALUE='Slow', $
/ALIGN_CENTER)
wFrameBase = WIDGET_BASE(wLeftBase, /COLUMN)
wFrameBaseLabel = WIDGET_LABEL(wFrameBase, $
VALUE = "Animation Frame:")
wFrameIndicatorBase = WIDGET_BASE(wFrameBase, $
TITLE = "Animation Frame", /COLUMN, /FRAME)
wFramesIndicatorSlider = WIDGET_SLIDER(wFrameIndicatorBase, $
/DRAG, VALUE = 0, UVALUE='INDICATOR', $
MAXIMUM = nframes - 1, MINIMUM = 0)
wActiveButton = CW_BGROUP(wFrameIndicatorBase, $
['Active Slider'], UVALUE='ACTIVE', $
FRAME=0, /NONEXCLUSIVE, /RETURN_INDEX, $
SET_VALUE=0) ; inactive
; Create the reset button if the reset keyword is set.
;
if (N_ELEMENTS(reset) NE 0) then begin
wResetButton = WIDGET_BUTTON(wLeftBase, $
VALUE='Reset', UVALUE='RESET')
endif else begin
wResetButton = 0L
endelse
; Create a widget base for the right column.
; It contains the drawing area.
;
wRightBase = WIDGET_BASE(wCWBase,/BASE_ALIGN_CENTER, /COLUMN)
wAreaDraw = WIDGET_DRAW(wRightBase, XSIZE=xsize, $
GRAPHICS_LEVEL=2, $
YSIZE=ysize, /BUTTON_EVENTS, UVALUE='DRAWING', $
RETAIN=0, /EXPOSE_EVENT, NOTIFY_REALIZE='Draw1CB')
; Initial transform, to be used when reset.
;
oMovableRotationModel->GetProperty, TRANSFORM=initTransform
; Get the current time.
;
starttime = systime(1)
; Initialize the time delay between frames .
;
delay = 2.0/(1.0 + 100.0)
; Initialize the button flags.
;
cycleFlag = 0 ; 0 = not in cycle mode, 1 = is in cycle mode
forwardFlag = 0 ; 0 = not in play forward mode, 1 = is
backwardFlag = 0 ; 0 = not in play forward mode, 1 = is
stopFlag = 1 ; 0 = playing, 1 = stopped
activeFlag = 0 ; 0 = frame indicator slider not active, 1 = active
; Initialize the frame index and icrement.
;
frameIndex = 0
frameIncrement = 1 ; 1 = play forward , -1 : play backward
count = 0 ; for calculating the frame speed rate.
rate = 0.0
vv = OBJARR(5)
; Create the sState.vector. To retrieve it outside cw_iat, do this :
;
; child = WIDGET_INFO( wCWBASE, /CHILD)
; WIDGET_CONTROL, child, GET_UVALUE = state
;
sState= { $
CurrentIndex: 0, $ ; Current frame index
PreviousIndex: 0, $ ; Previous frame index
btndown: 0b, $ ; Mouse button: 0=down, other: not down
dragq: 2, $ ; Drag quality: 0=low, 1=med. 2=high
facing: 'BOTH', $ ; Facing both sides
wAreaDraw: wAreaDraw, $ ; Widget draw ID
Delay : delay, $ ; Time delay between frames
OView: oView, $ ; View boject
OMovableModelArray: $
oMovableModelArray, $ ; Models
OMovableModel: $
oMovableModel, $
OMovableRotationModel: $
oMovableRotationModel, $
OMovableScalingModel: $
oMovableScalingModel, $
OStaticModelArray: $
oStaticModelArray, $
OContainer: oContainer, $ ; Container object
OTrack: oTrack, $ ; Trackball object
WTopBase: wTopBase, $ ; Top level base, parent of wCWBase
WCWBase: wCWBase, $ ; Top base of cw_iat
WRightBase: wRightBase, $ ; Parent base of the draw widget ID
WButtonBase: wButtonBase, $ ; Parent base of the buttons ID
WLeftBase: wLeftBase, $ ; Left column base ID
WPlayBButton: wPlayBButton, $ ; Play backward button ID
WStopButton: wStopButton, $ ; Stop button ID
WPlayFButton: wPlayFButton, $ ; Play forward button ID
WCycleButton: wCycleButton, $ ; Play in cycle button ID
WResetButton: wResetButton, $ ; Rest button ID
WActiveButton: wActiveButton, $; Active button ID
WFramesSpeedSlider: $
wFramesSpeedSlider, $ ; Animation speed slider ID
WFramesIndicatorSlider: $
wFramesIndicatorSlider, $ ; Frame indicator slider ID
WFramesRateLabel: $
wFramesRateLabel, $ ; Animation speed label ID
Nframes: nframes, $ ; Number of frames
ActiveFlag : activeFlag, $ ; 0=active button off, 1=on
ForwardFlag : forwardFlag, $ ; Play forward mode: 0=no, 1=yes
BackwardFlag : backwardFlag, $ ; Play backward mode: 0=no, 1=yes
StopFlag : stopFlag, $ ; Animation stopped: 0=no, 1=yes
CycleFlag : cycleFlag, $ ; Play in cycle: 0=no, 1=yes
InitTransform : initTransform, $ : Initial transformation
InitFlag : 0, $ ; Initial flag (1 only at start)
Count : count, $ ; Count the number of frames
Rate : rate, $ ; Animation rate (frames per sec.)
FrameIndex : FrameIndex, $ ; Current frame index
FrameIncrement : $
FrameIncrement, $ ; Frame index increment
BMB : BMB, $ ; Bitmap buttons structure
StartTime : startTime, $ ; Start time
FinalTime : startTime $ ; final time (for animation speed)
}
; Set the sState.as the user value of the first child of
; cCWBase identifier.
; To have access to the 'sState. outside of this compound widget
; do this :
;
; child = WIDGET_INFO(wCWBase, /CHILD)
; WIDGET_CONTROL, child, GET_UVALUE = sState. /NO_COPY
;
WIDGET_CONTROL, wLeftBase, SET_UVALUE=sState, /NO_COPY
WIDGET_CONTROL, wCWBase, EVENT_PRO = 'cw_iatEvent'
RETURN, wCWBase
end ; of cw_iat
; -----------------------------------------------------------------------------
;
; Purpose: Create a vibrating membrane data.
;
function vibmem, $
nFrames, $ ; IN: number of frames
index ; IN: function index (0 =< index < nFrames)
nx = 21 ; x dimension of the data set.
ny = 21 ; y dimension of the data set.
x = FIndGen(nx)/(nx-1)
y = FIndGen(ny)/(ny-1)
x = x # Replicate(1.,ny)
y = Replicate(1.,nx) # y
data = FLTARR(nx, ny)
; Mode
;
i = 3
j = 2
z = sin(i*!Pi*x) * sin(j*!Pi*y)
a = sin(FIndGen(nframes)*2*!Pi/nframes)
data = z * a(index)
RETURN, data
end
$Id: d_vibmembr.pro,v 1.19 1997/04/19 22:48:46 tremblay Exp $
;
; Copyright (c) 1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;
;+
; FILE:
; iniobj.pro
;
; PURPOSE:
; This procedure create the objects to be displayed
; by the IDL 5.0 animation tool (CW_IAT)
;
; CATEGORY:
; IDL 5.0
;
; CONTENTS:
; pro iniobj ; create and returns the objects.
;
; NAMED STRUCTURES:
; initStr
;
; COMMON BLOCS:
; none.
;
; MODIFICATION HISTORY:
; 9/96, DAT - Written.
;-
; -----------------------------------------------------------------------------
;
; Purpose: Function returns the created objects.
;
function iniobj, $
nframes, $ ; IN: number of frames
xdim, $ ; IN: x dimension of the data
ydim, $ ; IN: y dimension of the data
box = box ; IN: (opt) box around the main objects.
; Initialize parameters.
;
boxhere = N_ELEMENTS(box)
; Set the view such that the surface is
; contained within a box defined by
; by radx and rady ( view normal coordinates)
;
xAxis = -0.5 ; center the axes
yAxis = -0.5
zAxis = -0.5
sqr3 = sqrt(3)
radx = 2.0 ; viewport in normal coor.
rady = 2.0
xv = (1.0 - sqr3) /(2.0 * radx)
yv = (1.0 - sqr3) /(2.0 * rady)
width = 1.0 - 2 * xv
height = 1.0 - 2 * yv
myview = [xv+xAxis, yv+yAxis, width, height]
; Create the view.
;
oView = OBJ_NEW('idlgrview', PROJECTION=2, EYE=3, $
ZCLIP=[1.5,-1.5], VIEW=myview, COLOR=[0,0,0])
; Create the model tree.
;
oTopModel = OBJ_NEW('idlgrmodel')
oView->Add, oTopModel
; Scale the top model to fit the viewing area.
;
sct = 0.7
oTopModel->Scale, sct, sct, sct
oStaticModel = OBJ_NEW('idlgrmodel')
oStaticRotationModel = OBJ_NEW('idlgrmodel')
oStaticScalingModel = OBJ_NEW('idlgrmodel')
oMovableModel = OBJ_NEW('idlgrmodel')
oMovableRotationModel = OBJ_NEW('idlgrmodel')
oMovableScalingModel = OBJ_NEW('idlgrmodel')
oTopModel->Add, oMovableModel
oMovableModel->Add, oMovableRotationModel
oMovableRotationModel->Add, oMovableScalingModel
oTopModel->Add, oStaticModel
oStaticModel->Add, oStaticRotationModel
oStaticRotationModel->Add, oStaticScalingModel
; Create the model arrays (dimension is nFrames)
;
oStaticModelArray = OBJARR(nframes)
oMovableModelArray = OBJARR(nframes)
for i = 0,nframes-1 do begin
oStaticModelArray(i) = OBJ_NEW('idlgrmodel')
oMovableModelArray(i) = OBJ_NEW('idlgrmodel')
oStaticScalingModel->Add, oStaticModelArray(i)
oMovableScalingModel->Add, oMovableModelArray(i)
oMovableModelArray(i)->SetProperty, HIDE=1
endfor
; Create the surface data from the vibrating membrane
; function.
;
z = vibmem(nframes, 0)
sz = SIZE(z)
maxx = sz(1) - 1
maxy = sz(2) - 1
maxz = MAX(z, MIN=minz)
; Compute coordinate conversion to normalize.
;
xs = [0+xAxis,1.0/maxx]
ys = [0+yAxis,1.0/maxy]
minz2 = minz - 1
maxz2 = maxz + 1
zs = [-minz2/(maxz2-minz2)+zAxis, 1.0/(maxz2-minz2)]
; For height-fields, use the following vertex colors.
;
xdimension = sz(1)
ydimension = sz(2)
vertexColors = BYTARR(nframes,3,xdimension*ydimension,/nozero)
cbins=[[255, 0, 0], $
[255, 85, 0], $
[255, 170, 0], $
[255, 255, 0], $
[170, 255, 0], $
[ 85, 255, 0], $
[ 0, 255, 0]]
; Create the shades array.
;
shadesArray = FLTARR(nframes, xdimension, ydimension)
shades2 = FLTARR(nframes, xdimension* ydimension)
shades3 = FLTARR(nframes, xdimension* ydimension)
temp = fltarr(xdimension, ydimension)
zi = INTARR( 1,xdimension, ydimension)
xtot = xdimension * ydimension
; Shades array is color corresponding to hte vibrating
; membrane height (4-D mode).
;
for i = 0, nframes-1 do begin
temp = vibmem(nframes, i)
shadesArray(i, 0:xdimension-1, 0:ydimension-1) = $
temp(0:xdimension-1, 0:ydimension-1)
shades2(i, 0:xtot-1) = temp(0:xdimension-1, 0:ydimension-1)
endfor
shadesArray2 = shadesArray
; Shades array 2 is color corresponding to the bumps
; function ( 6-D mode).
;
for i = 0, nframes-1 do begin
temp = bumps(i + 40) ; 40 is any indice for bumps function
shadesArray2(i, 0:xdimension-1, 0:ydimension-1) = $
temp(0:xdimension-1, 0:ydimension-1)
shades3(i, 0:xtot-1) = temp(0:xdimension-1, 0:ydimension-1)
endfor
maxshades = MAX(shadesArray, MIN = minshades)
sat = 1.0
val = 1.0
maxangle = 225.0 ; ( angle is 0 < .. < 360 )
; Create the actual vertexcolors array corresponding
; to the vibrating membrane.
;
for i = 0, nframes-1 do begin
for j = 0, xtot-1 do begin
angle =ROUND( (shades2(i,j) - minshades) / $
(maxshades-minshades) * maxangle )
color_convert, angle, sat, val, red, green, blue, /hsv_rgb
vertexColors(i, 0, j) = red
vertexColors(i, 1, j) = green
vertexColors(i, 2, j) = blue
endfor
endfor
; Create the actual vertexcolors array corresponding
; to the bumps function.
;
vertexColors2 = vertexColors
maxshades = MAX(shadesArray2, MIN = minshades)
for i = 0, nframes-1 do begin
for j = 0, xtot-1 do begin
angle =ROUND( (shades3(i,j) - minshades) / $
(maxshades-minshades) * maxangle )
color_convert, angle, sat, val, red, green, blue, /hsv_rgb
vertexColors2(i, 0, j) = red
vertexColors2(i, 1, j) = green
vertexColors2(i, 2, j) = blue
endfor
endfor
; Create an obj array , Create 20 surfaces
;
oWaveSurfaceArray = OBJARR(nframes)
for i = 0, nframes-1 do begin
oWaveSurfaceArray(i) = OBJ_NEW('IDLgrSurface', z, $
STYLE=2, SHADING=0, COLOR=[60,60,255], BOTTOM=[64,192,128], $
XCOORD_CONV=xs, YCOORD_CONV=ys, ZCOORD_CONV=zs)
oMovableModelArray(i)->add,oWaveSurfaceArray(i)
zt = vibmem(nframes, i)
oWaveSurfaceArray(i)->setproperty, DATAZ=zt
endfor
; Create a box.
;
x = [ 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, $
1, 1, 0, 1, 1 ]
y = [ 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, $
1, 1, 1, 1, 0 ]
z = [ 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, $
1, 0, 0, 0, 0 ]
x2 = [ 0.0, 0.0, 0.0, 0.0, 0.0]
y2 = [ 0.0, 0.0, 0.0, 0.0, 0.0]
z2 = [ 0.0, 0.0, 0.0, 0.0, 0.0]
x3 = FINDGEN(5)
y3 = FINDGEN(5)
z3 = FINDGEN(5)
if (box EQ 1) then begin
olineArray = objarr(20)
for i = 0, nframes-1 do begin
olinearray(i) = OBJ_NEW('idlgrpolyline',x,y,z, $
COLOR=[255,0,0], THICK=2)
oStaticModelArray(i)->add,olinearray(i)
endfor
endif ; of if box
; Create some light.
;
m = OBJ_NEW('idlgrmodel')
oLight1 = OBJ_NEW('IDLgrLight', LOC=[2,2,2], TYPE=1)
m->add,oLight1
oLight2 = OBJ_NEW('IDLgrLight', TYPE=0, INTENSITY=0.5)
m->add,oLight2
OView->add,m
; Create a solid line style
;
for i = 0, nframes-1 do begin
oWaveSurfaceArray(i)->SetProperty, LINESTYLE=4294967295L
endfor
; Rotate and translate the surfaces
; Show them one by one
;
for i = 0, nframes-1 do begin
oMovableModelArray(i)->rotate,[1,0,0],-90
oMovableModelArray(i)->rotate,[0,1,0],30
oMovableModelArray(i)->rotate,[1,0,0],30
endfor
; Get the initial transform, to be used when reset.
;
oMovableModelArray(0)->GetProperty, TRANSFORM=initTransform
oMovableModelArray(0)->GetProperty, TRANSFORM=t
; Add the trackball object for interactive change
; of the scene orientation.
;
oTrack = OBJ_NEW('Trackball', [xdim/2.0, ydim/2.0], xdim/2.0)
oContainer = OBJ_NEW('IDLgrContainer')
oContainer->Add, oView
oContainer->Add, oTrack
; Save information into the structure
;
initStr = { $
Nframes : nframes, $
Xdim : xdim, $
Ydim : ydim, $
OTopModel: oTopModel, $
OTrack: oTrack, $
OContainer: oContainer, $
OMovableModel: oMovableModel, $
OMovableRotationModel: oMovableRotationModel, $
OMovableScalingModel: oMovableScalingModel, $
OMovableModelArray: oMovableModelArray, $
OWaveSurfaceArray: oWaveSurfaceArray, $
OView: oView, $
OStaticModelArray: oStaticModelArray, $
VertexColors: vertexColors, $
VertexColors2: vertexColors2, $
Xtot : xtot, $
InitTransform : initTransform $
}
RETURN, initStr
end ; of iniobj.pro
pro vib_SetShades, $
initial, $ ; IN: initial frame index
final, $ ; IN: final frame index
event ; IN: event structure
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
tempColor = INTARR( 3, info.xtot)
if (initial LT final) then begin
for i = initial, final do begin
tempColor(0:2, 0:info.xtot-1) = $
info.vertexColors(i, 0:2, 0:info.xtot-1)
info.oWaveSurfaceArray(i)->setproperty, $
VERT_COLORS=tempColor
endfor
endif else begin
for i = initial, final, -1 do begin
tempColor(0:2, 0:info.xtot-1) = $
info.vertexColors2(i, 0:2, 0:info.xtot-1)
info.oWaveSurfaceArray(i)->setproperty, $
VERT_COLORS=tempColor
endfor
endelse
info.drawWindowObjID->draw,info.oView
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of vib_SetShades
; -----------------------------------------------------------------------------
;
; Purpose: Toggle the vertex off and vertex on button.
;
function Toggle_state, $
wid ; IN: widget identifer
WIDGET_CONTROL, wid, GET_VALUE = name
s = STRPOS(name,'(off)')
if (s NE -1) then begin
strput,name,'(on )',s
ret = 1
endif else begin
s = strpos(name,'(on )')
strput,name,'(off)',s
ret = 0
endelse
WIDGET_CONTROL, wid, SET_VALUE = name
RETURN, ret
end
; -----------------------------------------------------------------------------
;
; Purpose: Main event handler.
;
pro vibmembr_event, $
event ; IN: event structure
; Quit the application using the close box.
;
if (TAG_NAMES(event, /STRUCTURE_NAME) EQ $
'WIDGET_KILL_REQUEST') then begin
WIDGET_CONTROL, event.top, /DESTROY
RETURN
endif
; Open a widget message if the user try to quit
; using the close box (not the quit button of the application).
;
if (TAG_NAMES(Event, /STRUCTURE_NAME) eq 'WIDGET_KILL_REQUEST') $
then begin
v = WIDGET_MESSAGE('Use the File/Quit menu item to ' + $
'close this application.')
endif
case WIDGET_INFO(event.id,/NAME) of
; Now handle the button events
;
'BUTTON' : begin
; Get the event user value and branch to that event.
;
WIDGET_CONTROL, event.id, GET_UVALUE=uval
case uval of
; Change the surface into a wire style.
;
'WIRE' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
stylestring = 'Wire'
info.stylestring = 'Wire'
for i = 0, info.nframes-1 do begin
info.oWaveSurfaceArray(i)->SetProperty, STYLE=1
endfor
info.dragq = 0
info.drawWindowObjID->SetProperty, QUALITY=info.dragq
info.drawWindowObjID->Draw, info.oView
WIDGET_CONTROL, info.wSolidButton, SENSITIVE=1
WIDGET_CONTROL, info.wWireButton, SENSITIVE=0
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of WIRE
; Change the surface into a solid style.
;
'SOLID' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
stylestring = 'Solid'
info.stylestring = 'Solid'
for i = 0, info.nframes-1 do begin
info.oWaveSurfaceArray(i)->SetProperty, STYLE=2
endfor
WIDGET_CONTROL, info.wSolidButton, SENSITIVE=0
WIDGET_CONTROL, info.wWireButton, SENSITIVE=1
if (info.dragq EQ 0) then begin
info.dragq = 2
info.drawWindowObjID->SetProperty, QUALITY=info.dragq
endif else if (info.dragq EQ 1) then begin
WIDGET_CONTROL, info.wMediumButton, sensitive = 0
endif else begin
WIDGET_CONTROL, info.wHighButton, sensitive = 0
endelse
info.drawWindowObjID->draw,info.oView
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of SOLID
; Change the shading to flat.
;
'FLAT' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
shadingstring = 'Flat'
info.shadingstring = 'Flat'
for i = 0, info.nframes-1 do begin
info.oWaveSurfaceArray(i)->SetProperty, SHADING=0
endfor
info.drawWindowObjID->draw,info.oView
WIDGET_CONTROL, info.wFlatButton, SENSITIVE=0
WIDGET_CONTROL, info.wGouraudButton, SENSITIVE=1
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of FLAT
; Change the shading to Gouraud.
;
'GOURAUD' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
for i = 0, info.nframes-1 do begin
info.oWaveSurfaceArray(i)->SetProperty, SHADING=1
endfor
info.drawWindowObjID->draw,info.oView
shadingstring = 'Gouraud'
info.shadingstring = 'Gouraud'
WIDGET_CONTROL, info.wFlatButton, SENSITIVE=1
WIDGET_CONTROL, info.wGouraudButton, SENSITIVE=0
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of GOURAUD
; Change the surface to show 4 dimensions.
;
'FOURD' : begin
; If the vertex colors are on, set the shade
; frames in order,
; hence showing the surface height.
;
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
WIDGET_CONTROL, info.wNoColorButton, SENSITIVE=1
WIDGET_CONTROL, info.wFourDButton, SENSITIVE=0
WIDGET_CONTROL, info.wFiveDButton, SENSITIVE=1
nframes = info.nframes
nFrames = info.nFrames
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
vib_SetShades, 0, nframes-1, event
end ; of FOURD
; Change the surface to show 5 dimensions.
;
'FIVED' : begin
; Set the shades colors to show the
; 'bumps' function values.
; Toggle the vertex color button to on.
;
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
WIDGET_CONTROL, info.wNoColorButton, SENSITIVE=1
WIDGET_CONTROL, info.wFourDButton, SENSITIVE=1
WIDGET_CONTROL, info.wFiveDButton, SENSITIVE=0
nFrames = info.nFrames
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
vib_SetShades, nframes-1, 0, event
end ; of FIVED
; Set the surface to be monochromatic (one color).
;
'NOCOLOR' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
WIDGET_CONTROL, info.wNoColorButton, SENSITIVE=0
WIDGET_CONTROL, info.wFourDButton, SENSITIVE=1
WIDGET_CONTROL, info.wFiveDButton, SENSITIVE=1
tempColor = INTARR( 3, info.xtot)
topColor = INTARR(3)
bottomColor = INTARR(3)
info.oWaveSurfaceArray(0)->getproperty, COLOR=topColor
info.oWaveSurfaceArray(0)->getproperty, BOTTOM=bottomColor
nframes = info.nframes
for i = 0, info.nframes-1 DO begin
info.oWaveSurfaceArray(i)->SetProperty, $
VERT_COLORS=0
info.oWaveSurfaceArray(i)->SetProperty, $
COLOR=topColor
info.oWaveSurfaceArray(i)->SetProperty, $
BOTTOM=bottomColor
endfor
info.drawWindowObjID->draw,info.oView
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of NOCOLOR
; Set drag quality to low.
;
'LOW' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
child = WIDGET_INFO( info.wCWBase, /CHILD)
WIDGET_CONTROL, child, GET_UVALUE = state, /NO_COPY
info.dragq = 0
state.dragq = 0
WIDGET_CONTROL, child, SET_UVALUE = state, /NO_COPY
WIDGET_CONTROL, info.wLowButton, SENSITIVE=0
WIDGET_CONTROL, info.wMediumButton, SENSITIVE=1
WIDGET_CONTROL, info.wHighButton, SENSITIVE=1
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of LOW
; Set drag quality to medium.
;
'MEDIUM' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
child = WIDGET_INFO( info.wCWBase, /CHILD)
WIDGET_CONTROL, child, GET_UVALUE = state, /NO_COPY
info.dragq = 1
state.dragq = 1
WIDGET_CONTROL, child, SET_UVALUE = state, /NO_COPY
WIDGET_CONTROL, info.wLowButton, SENSITIVE=1
WIDGET_CONTROL, info.wMediumButton, SENSITIVE=0
WIDGET_CONTROL, info.wHighButton, SENSITIVE=1
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of MEDIUM
; Set drag quality to high.
;
'HIGH' : begin
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
child = WIDGET_INFO( info.wCWBase, /CHILD)
WIDGET_CONTROL, child, GET_UVALUE = state, /NO_COPY
info.dragq = 2
state.dragq = 2
WIDGET_CONTROL, child, SET_UVALUE = state, /NO_COPY
WIDGET_CONTROL, info.wLowButton, SENSITIVE=1
WIDGET_CONTROL, info.wMediumButton, SENSITIVE=1
WIDGET_CONTROL, info.wHighButton, SENSITIVE=0
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
end ; of HIGH
; Display the information file.
;
'INFO' : begin
if (Xregistered('XDisplayFile') NE 0) then RETURN
XDisplayFile, filepath("vibmembr.txt", $
SUBDIR=['examples', 'demo', 'demotext']), $
DONE_BUTTON='Done', $
TITLE="About intereactive 6-D visualizations", $
GROUP=event.top, WIDTH=55, HEIGHT=14
end ; of INFO
; Quit thie application.
;
'QUIT' : begin
WIDGET_CONTROL, event.top, /DESTROY
RETURN
end ; of QUIT
endcase ; of case uval in BUTTON
end ; of BUTTON case
ELSE : ; do nothing
endcase ; of case widget_info(name)
end ; of vibmembr_event
; -----------------------------------------------------------------------------
;
; Purpose: Cleanup procedure. Destroy the objects and
; restore the previous color table.
;
pro vibmembr_cleanup, $
wTopBase ; IN: top level base identifier
WIDGET_CONTROL, wTopBase, GET_UVALUE=info, /NO_COPY
; Restore the color table
;
TVLCT, info.colorTable
; Destroy the top objects
;
OBJ_DESTROY, info.oView
OBJ_DESTROY, info.oTrack
OBJ_DESTROY, info.oContainer
; Map the group leader base if it exists.
;
if (WIDGET_INFO(info.groupBase, /VALID_ID)) then $
WIDGET_CONTROL, info.groupBase, /MAP
end ; of vibmembr_cleanup
; -----------------------------------------------------------------------------
;
; Purpose: Animate a series of surface objects (in IDL 5.0).
; The scheme is to precompute the surface height for
; n frames. The 'animation' is made by displaying
; successively each frames ( or objects)
;
pro d_vibmembr, $
Box = box, $ ; IN: (opt) create a box arou d the surface
GROUP=group, $ ; IN: (opt) Group leader
APPTLB = appTLB ; OUT: (opt) TLB of this application
; Check the validity of the group identifier.
;
ngroup = N_ELEMENTS(group)
if (ngroup NE 0) then begin
check = WIDGET_INFO(group, /VALID_ID)
if (check NE 1) then begin
print,'Error, the group identifier is not valid'
print, 'Return to the main application'
RETURN
endif
groupBase = group
endif else groupBase = 0L
checkBox = N_ELEMENTS(box)
; Save the color table
;
TVLCT, savedR, savedG, savedB, /GET
colorTable = [ [savedR], [savedG], [savedB] ]
; Make the system to have a maximum of 256 colors.
;
if ((( !D.NAME EQ 'X') OR (!D.NAME EQ 'MAC')) $
AND (!D.N_COLORS GE 256L)) then $
DEVICE, PSEUDO_COLOR=8
DEVICE, DECOMPOSED=0, BYPASS_TRANSLATION=0
; Determine hardware display size.
;
DEVICE, GET_SCREEN_SIZE=screenSize
; Make the drawing area proportional to the
; screen size.
;
drawXSize = 0.6 * screenSize(0)
drawYSize = 0.8 * drawXSize
; Get the tips.
;
sText = getTips(filepath('vibmembr.tip', $
SUBDIR=['examples','demo', 'demotext']) )
; Initialize parameter / constants
;
nframes = 20 ; number of frames
reset = 1 ; have a reset button in the compound widget)
xdim = drawXSize
ydim = drawYSize
; Initialize all the objects
;
objectStr = iniobj(nframes, xdim, ydim, Box = checkbox)
; Create widgets.
;
if (ngroup EQ 0) then begin
wTopBase = WIDGET_BASE(/COLUMN, $
TLB_FRAME_ATTR=1, MBAR=barbase, $
XPAD=0, YPAD=0, $
/TLB_KILL_REQUEST_EVENTS, $
TITLE="Vibrating Membrane")
endif else begin
wTopBase = WIDGET_BASE(/COLUMN, $
GROUP_LEADER=parent, $
XPAD=0, YPAD=0, $
TLB_FRAME_ATTR=1, MBAR=barbase, $
/TLB_KILL_REQUEST_EVENTS, $
TITLE="Vibrating Membrane")
endelse
; Create the file menu bar item that contains the quit button.
;
wFileButton = WIDGET_BUTTON(barbase,Value = 'File', /MENU)
wQuitButton = WIDGET_BUTTON(wFileButton, $
VALUE='Quit', UVALUE='QUIT')
; Create the option menu .
;
wOptionButton = WIDGET_BUTTON(barbase, VALUE='Options', /MENU)
wStyleButton = WIDGET_BUTTON(wOptionButton, $
VALUE='Style', UVALUE='Style', /MENU)
wWireButton = WIDGET_BUTTON(wStyleButton, $
VALUE='Wire', UVALUE='WIRE')
wSolidButton = WIDGET_BUTTON(wStyleButton, $
VALUE='Solid', UVALUE='SOLID')
wShadingButton = WIDGET_BUTTON(wOptionButton, $
VALUE='Shading', UVALUE='Shading', /MENU)
wFlatButton = WIDGET_BUTTON(wShadingButton, $
VALUE='Flat', UVALUE='FLAT')
wGouraudButton = WIDGET_BUTTON(wShadingButton, $
VALUE='Gouraud', UVALUE='GOURAUD')
wQualityButton = WIDGET_BUTTON(wOptionButton, $
VALUE='Drag Quality', UVALUE='QUALITY', /MENU)
wLowButton = WIDGET_BUTTON(wQualityButton, $
VALUE='Low', UVALUE='LOW')
wMediumButton = WIDGET_BUTTON(wQualityButton, $
VALUE='Medium', UVALUE='MEDIUM')
wHighButton = WIDGET_BUTTON(wQualityButton, $
VALUE='High', UVALUE='HIGH')
wVertexButton = WIDGET_BUTTON(wOptionButton, $
VALUE='Vertex Colors', /MENU, UVALUE='VERTEX')
wNoColorButton = WIDGET_BUTTON(wVertexButton, $
VALUE='Monochromatic', UVALUE='NOCOLOR')
wFourDButton = WIDGET_BUTTON(wVertexButton, $
VALUE='4 Dimensions', UVALUE='FOURD')
wFiveDButton = WIDGET_BUTTON(wVertexButton, $
VALUE='5 Dimensions', UVALUE='FIVED')
; Create the menu bar item help that contains the about button.
;
wHelpButton = WIDGET_BUTTON(barbase,Value = 'About', /HELP, /Menu)
wAboutButton = WIDGET_BUTTON(wHelpButton, $
VALUE='About Vibrating Membrane', UVALUE='INFO')
; Call the compound widget that creates the core
; of the animation tool.
;
wCWBase = cw_iat(wTopBase, $
objectStr.oStaticModelArray, objectStr.oMovableModelArray, $
objectStr.oMovableModel, objectStr.oMovableRotationModel, $
objectStr.oMovableScalingModel, $
objectStr.oView, $
objectStr.oTrack, $
objectStr.oContainer, nframes, $
XSIZE=xdim, YSIZE=ydim, $
RESET=reset, STATUS=cwStatus)
; Check the status of the cw_iat
;
if (cwStatus EQ 0) then begin
MESSAGE,'The creation of the compound widget was not successful'
RETURN
endif
; Create tips texts.
;
wStatusBase = WIDGET_BASE(wTopBase, MAP=0, /ROW)
nWidgets = 2
wText = LONARR(nWidgets)
widTips, wStatusBase, sText.text, XSIZE=36, $
YSIZE=3, NWIDGETS=nWidgets, wText
; Now, all the widget have been created....
; Realize the widget hierarchy.
;
WIDGET_CONTROL, wTopBase, /REALIZE
; Returns the top level base to the APPTLB keyword.
;
appTLB = wtopBase
; Size the tips widgets.
;
sizeTips, wTopBase, wText, wStatusBase
; Get the info structure of the compound widget CW_IAT
;
child = WIDGET_INFO( wCWBase, /CHILD)
WIDGET_CONTROL, child, GET_UVALUE = state, /NO_COPY
; Get the base that has the TIMER user value.
; Make the stop flag to 0 ( not stopped)
; so that we can animate at start up.
;
wButtonBase = state.wButtonBase
state.stopFlag = 0
; Get the window object of CW_IAT.
;
wAreaDraw = state.wAreaDraw
WIDGET_CONTROL, state.wRightBase, GET_UVALUE = temp, /NO_COPY
drawWindowObjID = temp
WIDGET_CONTROL, state.wRightBase, SET_UVALUE = temp, /NO_COPY
; Desensitize the frame indicator slider.
;
WIDGET_CONTROL, state.wFramesIndicatorSlider, SENSITIVE=0
; Set the play forward button on, and the stop to off.
;
WIDGET_CONTROL, state.wStopButton, SET_VALUE=state.BMB.stop
WIDGET_CONTROL, state.wPlayFButton, SET_VALUE=state.BMB.forwardOn
; Show each seperate frames.
;
tempColor = INTARR( 3, objectStr.xtot)
for i = 0, nframes-1 do begin
objectStr.oMovableModelArray(i)->SetProperty, HIDE=0
objectStr.oWaveSurfaceArray(i)->SetProperty, SHADING=1
tempColor(0:2, 0:objectStr.xtot-1) = $
objectStr.vertexColors(i, 0:2, 0:objectStr.xtot-1)
objectStr.oWaveSurfaceArray(i)->SetProperty, $
VERT_COLORS=tempColor
drawWindowObjID->draw,objectStr.oView
objectStr.oMovableModelArray(i)->SetProperty, HIDE=1
WIDGET_CONTROL, state.wFramesIndicatorSlider, SET_VALUE=i
endfor
; Set the frame indicator slider to 0.
;
WIDGET_CONTROL, state.wFramesIndicatorSlider, $
SET_SLIDER_MAX=nframes-1
WIDGET_CONTROL, state.wFramesIndicatorSlider, SET_VALUE=0
; Get the drag quality as set by cw_iat.
; And the compound widget toplevel base ID.
;
wCWBase = state.wCWBase
dragq = state.dragq
; Sensitize the compound widget.
;
WIDGET_CONTROL, child, SET_UVALUE=state, /NO_COPY
WIDGET_CONTROL, wCWBase, SENSITIVE=1
; Create the info structure of the main application.
;
info = { $
dragq: dragq, $ ; Drag quality: 0=low, 1=med. 2=high
ColorTable: colorTable, $ ; Color table to restore
facing: 'BOTH', $ ; Showing both sides
wAreaDraw: wAreaDraw, $ ; Widget draw ID
OWaveSurfaceArray: $
objectStr.oWaveSurfaceArray, $ ; Surface object array
OView: objectStr.oView, $ ; Main view object
OTrack: objectStr.oTrack, $ ; Trackball object
OContainer: objectStr.oContainer, $ ; Container object
oStaticModelArray: $
objectStr.oStaticModelArray, $ ; Models
OMovableModelArray: $
objectStr.oMovableModelArray, $
OMovableModel: $
objectStr.oMovableModel, $
OMovableRotationModel: $
objectStr.oMovableRotationModel, $
OMovableScalingModel: $
objectStr.oMovableScalingModel, $
VertexColors: $
objectStr.vertexColors, $ ; Vertices colors (4-D)
VertexColors2: $
objectStr.vertexColors2, $ ; Vertices colors (5-D)
DrawWindowObjID: drawWindowObjID, $ ; Window object
Barbase : barbase, $ ; Menu bar base ID
WTopBase: wTopBase, $ ; Top level base
WCWBase: wCWBase, $ ; Compound widget top level base
WQuitButton: wQuitButton, $ ; Functionality button IDs
WWireButton: wWireButton, $
WSolidButton: wSolidButton, $
WFlatButton: wFlatButton, $
WGouraudButton: wGouraudButton, $
WNoColorButton: wNoColorButton, $
WFourdButton: wFourDButton, $
WFivedButton: wFiveDButton, $
WVertexButton: wVertexButton, $
WLowButton: wLowButton, $
WMediumButton: wMediumButton, $
WHighButton: wHighButton, $
Stylestring : 'Solid', $ ; String indicating the style
Shadingstring : 'Flat', $ ; String indicating the shading
Nframes: nframes, $ ; Number of frames
Xtot : objectStr.xtot, $ ; Product of x dim by y dim of data set.
groupBase: groupBase $ ; Base of Group Leader
}
WIDGET_CONTROL, wTopBase, SET_UVALUE=info, /NO_COPY
; Desensitize the stop button.
;
WIDGET_CONTROL, wFourDButton, SENSITIVE=0
WIDGET_CONTROL, wGouraudButton, SENSITIVE=0
WIDGET_CONTROL, wSolidButton, SENSITIVE=0
; Desensitize the medium and high drag quality buttons.
;
WIDGET_CONTROL, wLowButton, SENSITIVE=1
WIDGET_CONTROL, wMediumButton, SENSITIVE=1
WIDGET_CONTROL, wHighButton, SENSITIVE=0 ; this was set in cw_iat
; Make the kill request sensitive. This make the
; event created by the quit and close button from
; the opreating system to be gently recognied and processed.
;
WIDGET_CONTROL, wTopBase,/TLB_KILL_REQUEST_EVENTS
objectStr.oMovableModelArray(0)->SetProperty, HIDE=0
objectStr.oStaticModelArray(0)->SetProperty, HIDE=0
; Animate at start.
;
pseudoEvent = { $
ID: wButtonBase, $
Top: wTopBase, $
Handler:wCWBAse $
}
cw_iatEvent, pseudoEvent
XMANAGER, 'd_vibmembr', wTopBase, EVENT_HANDLER='vibmembr_event', $
CLEANUP='vibmembr_cleanup', /NO_BLOCK
end